<?php


namespace app\api\controller;

//http://cosmo.com/api/Userdiscount/getUserDiscountList
use app\api\model\Userdiscount as userDiscountModel;
class Userdiscount extends BaseApi {

    //我的优惠券
    public function getUserDiscountList(){

        if(!$this->request->param('openid')){
            return json(['code'=>-1,'msg'=>'缺少参数']);
        }

        $userDiscount = new userDiscountModel();

        $userDiscountList = $userDiscount->getUserDiscountList(trim($this->request->param('openid')));

        if(!$userDiscountList->isEmpty()){
            return json(['code'=>1,'data'=>$userDiscountList]);
        }

        return json(['code'=>-1,'msg'=>'暂无优惠券']);
    }

}